/*
 * @lc app=leetcode.cn id=69 lang=javascript
 *
 * [69] Sqrt(x)
 */

// @lc code=start
/**
 * @param {number} x
 * @return {number}
 */
var mySqrt = function (x) {
  let res = 1;

  while (res * res < x) {
    res++;
  }

  return res * res === x ? res : res - 1;
};
// @lc code=end
